program Problem2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type arr= array of integer;

var i,j: integer;
    a: arr;
    fin, fon: textfile;
    n: integer;
    h: integer; 
    s: integer;
begin
  assignfile(fin, 'in.txt');
  assignfile(fon, 'out.txt');
  reset(fin);
  rewrite(fon);
  Read(fin, n);
  Setlength (a, n);

  For i:=0 to n-1 do
    Read (fin, a[i]);
  For i:=0 to n-2 do
    For j:=0 to n-2 do
      If a[j]>a[j+1] then
      begin
        h:=a[j];
        a[j]:=a[j+1];
        a[j+1]:=h;
      end;
      
  s:=a[0]+a[n-1];
  Write(fon, s);
  close(fin);
  close(fin);
  Readln;
  Readln;
end.
